package com.hlkj.pay.app.common.ext.tencent;
/*
 * Hlpay-Plus aggregate payment system.
 * Copyright (c) 2024-2025 Hlpay Team Copyright has the right of final interpretation.
 */

import com.hlkj.pay.dto.common.OcrConfig;
import com.hlkj.pay.dto.common.SmsConfig;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.ocr.v20181119.OcrClient;
import com.tencentcloudapi.sms.v20210111.SmsClient;
import org.springframework.util.StringUtils;
/**
 * @author HlpayTeam
 * @date 2024/09/13 13:38
 */
public class TencentCommon {
	/*
	 * sms
	 * @param secretId
	 * @param secretKey
	 * @return
	 */
	public SmsClient smsClient(SmsConfig smsConfig) {
		Credential cred = new Credential(smsConfig.getSecretId(), smsConfig.getSecretKey());
		HttpProfile httpProfile = new HttpProfile();
		httpProfile.setConnTimeout(60);
		ClientProfile clientProfile = new ClientProfile();
		clientProfile.setHttpProfile(httpProfile);
		clientProfile.setDebug(true);
		String region = smsConfig.getRegion();
		if(StringUtils.isEmpty(region)){
			region="ap_hangzhou";
		}
		SmsClient client = new SmsClient(cred, region,clientProfile);
		return client;
	}
	/*
	 * sms
	 * @param secretId
	 * @param secretKey
	 * @return
	 */
	public OcrClient ocrClient(OcrConfig ocrConfig) {
		Credential cred = new Credential(ocrConfig.getSecretId(), ocrConfig.getSecretKey());
		HttpProfile httpProfile = new HttpProfile();
		httpProfile.setConnTimeout(60);
		ClientProfile clientProfile = new ClientProfile();
		clientProfile.setHttpProfile(httpProfile);
		clientProfile.setDebug(true);
		String region = ocrConfig.getRegion();
		if(StringUtils.isEmpty(region)){
			region="ap_hangzhou";
		}
		OcrClient client = new OcrClient(cred, region,clientProfile);
		return client;
	}
}
